package model23.fangwen;

import java.util.LinkedList;
import java.util.List;

/**
 * @Author ilongsay
 * @Date: Create in 2019/10/14 23:25
 * @Description: don't bb,show you code
 */
public class ObjectStructrue {

    //维护一个集合
    private List<AbstractPerson> abstractPersonList = new LinkedList<>();

    public void add(AbstractPerson abstractPerson) {
        abstractPersonList.add(abstractPerson);
    }

    public void remove(AbstractPerson abstractPerson) {
        abstractPersonList.remove(abstractPerson);
    }

    //遍历显示
    public void display(Action action) {
        for (AbstractPerson abstractPerson : abstractPersonList) {
            abstractPerson.accept(action);
        }
    }
}
